<%@ page language="java" contentType="text/html; charset=utf-8"
     pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head id="MyHead">
<script src="../resources/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../resources/Scripts/jquery.easyui.min-1.3.5.js"
	type="text/javascript"></script>
<script src="../resources/Scripts/jquery.datagrid.js" type="text/javascript"></script>
<script src="../resources/Scripts/JScriptIndex.js" type="text/javascript"></script>
<link href="../resources/Content/Default.css" rel="stylesheet" type="text/css" />
<link href="../resources/Content/IndexStyle.css" rel="stylesheet" type="text/css" />

<link href="../resources/Res/easyui/themes/icon.css" rel="stylesheet"
	type="text/css" />
<script src="../resources/Res/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>
<link href="../resources/Res/easyui/themes/default/easyui.css" rel="stylesheet"
	type="text/css" />
<title>C_Car</title>
<script type="text/javascript" language="javascript">
	$(function() {
		$
				.extend(
						$.fn.datagrid.methods,
						{
							addToolbarItem : function(jq, items) {
								return jq
										.each(function() {
											var dpanel = $(this).datagrid(
													'getPanel');
											var toolbar = dpanel
													.children("div.datagrid-toolbar");
											if (!toolbar.length) {
												toolbar = $(
														"<div class=\"datagrid-toolbar\"><table cellspacing=\"0\" cellpadding=\"0\"><tr></tr></table></div>")
														.prependTo(dpanel);
												$(this).datagrid('resize');
											}
											var tr = toolbar.find("tr");
											for (var i = 0; i < items.length; i++) {
												var btn = items[i];
												if (btn == "-") {
													$(
															"<td><div class=\"datagrid-btn-separator\"></div></td>")
															.appendTo(tr);
												} else {
													var td = $("<td></td>")
															.appendTo(tr);
													var b = $(
															"<a href=\"javascript:void(0)\"></a>")
															.appendTo(td);
													b[0].onclick = eval(btn.handler
															|| function() {
															});
													b.linkbutton($.extend({},
															btn, {
																plain : true
															}));
												}
											}
										});
							},
							removeToolbarItem : function(jq, param) {
								return jq
										.each(function() {
											var dpanel = $(this).datagrid(
													'getPanel');
											var toolbar = dpanel
													.children("div.datagrid-toolbar");
											var cbtn = null;
											if (typeof param == "number") {
												cbtn = toolbar.find("td").eq(
														param).find(
														'span.l-btn-text');
											} else if (typeof param == "string") {
												cbtn = toolbar
														.find("span.l-btn-text:contains('"
																+ param + "')");
											}
											if (cbtn && cbtn.length > 0) {
												cbtn.closest('td').remove();
												cbtn = null;
											}
										});
							}
						});
	});
</script>


<script type="text/javascript" language="javascript">
	$(function() {

		var currTab = window.top.$('#tabs').tabs('getSelected'); //获得当前tab
		var iframeid = $(currTab.panel('options').content).attr('id');

		//关闭AJAX相应的缓存
		$.ajaxSetup({
			cache : false
		});

		$.post("../resources/Home/GetToolbar", {
			id : iframeid
		}, function(data) {
			if (data == null) {
				return;
			}

			var ExportExcel = [ {
				text : '导出EXCEL',
				iconCls : 'icon-excel',
				handler : function(e) { //打印
					flexiExport();
				}
			} ];

			//alert(data);
			//$('#toolbar').html(data);
			$('#flexigridData').datagrid("addToolbarItem", data);
			$('#flexigridData').datagrid("addToolbarItem", ExportExcel);
		});

		$('#flexigridData').datagrid({
			//title: '车辆费用汇总', //列表的标题
			iconCls : 'icon-site',
			width : 'auto',
			height : 'auto',
			nowrap : true,
			striped : true,
			collapsible : true,
			url : '/Summary', //获取数据的url
			sortName : 'ciId',
			sortOrder : 'desc',
			idField : 'ciId',

			toolbar : [
			{
				text : '查询',
				iconCls : 'icon-search',
				handler : function() {
					flexiQuery();
				}
			}

			],
			columns : [ [ 
			             {
				field:'ciId',title:'数据',width:150,hidden:'true'}, 
			              {
				field : 'ciPlatenumber',
				title : '<label for="ciPlatenumber">车牌号</label>',
				width : 80,
				styler : function(value, row, index) {
					return 'background-color:#336699;color:white';
				}
			}, /* {
				field : 'C_sno',
				title : '<label for="C_sno">车牌小号</label>',
				width : 80,
				styler : function(value, row, index) {
					return 'background-color:#e8e8ff';
				}
			}, */ {
				field : 'ciBranchschool',
				title : '<label for="ciBranchschool">所在分校</label>',
				width : 60,
				styler : function(value, row, index) {
					return 'background-color:#e8e8ff';
				}
			}, {
				field : 'ciSitenumber',
				title : '<label for="ciSitenumber">场地编号</label>',
				width : 80,
				styler : function(value, row, index) {
					return 'background-color:#e8e8ff';
				}
			}, {
				field : 'oilMoney',
				title : '<label for="oilMoney">加油总费用</label>',
				width : 100,
				styler : function(value, row, index) {
					return 'background-color:#d7fff0';
				}
			}, {
				field : 'repairMoney',
				title : '<label for="repairMoney">维修总费用</label>',
				width : 100,
				styler : function(value, row, index) {
					return 'background-color:#f0dad2';
				}
			},
				{
				field : 'breakMoney',
				title : '<label for="breakMoney">违章总金额</label>',
				width : 100,
				styler : function(value, row, index) {
					return 'background-color:#f0dad2';
				}
			},
				{
				field : 'accMoney',
				title : '<label for="accMoney">事故理赔总金额</label>',
				width : 100,
				styler : function(value, row, index) {
					return 'background-color:#d7fff0';
				}
			}, 
				{
				field : 'allMoney',
				title : '<label for="allMoney">总费用</label>',
				width : 100,
				styler : function(value, row, index) {
					return 'background-color:#b45b3e;color:white';
				}
			} ] ],
			pagination : true,
			rownumbers : true

		});
	});
	//“查询”按钮，弹出查询框
	function flexiQuery() {
		$('#divQuery')
				.dialog(
						{
							buttons : [
									{
										text : '查询',
										iconCls : 'icon-ok',
										handler : function() {
											//执行查询                        
											$('#flexigridData').datagrid(
													'reload', {
														//车牌号
														C_no : $('#C_no').val(),
														//车牌小号
														C_sno:$('#C_sno').val(),
														//场地编号
														C_Pno : $('#C_Pno').val(),
														//车型
														C_typeDDL_String : $('#C_typeDDL_String').val(),
														//车主
														C_master : $('#C_master').val(),
														//档案编号
														C_filesNo : $('#C_filesNo').val(),
														//司机
														C_dirver : $('#C_dirver').val(),
														//驾驶员身份证号
														C_GPSNO : $('#C_GPSNO').val(),
														
														
													});
										}
									}, {
										text : '取消',
										iconCls : 'icon-cancel',
										handler : function() {
											$('#divQuery').dialog("close");
										}
									} ]

						});
		$('#divQuery').dialog("open");
	};

	//“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
	function flexiSelect() {

		var rows = $('#flexigridData').datagrid('getSelections');
		if (rows.length == 0) {
			$.messager.alert('操作提示', '请选择数据!', 'warning');
			return false;
		}

		var arr = [];
		for (var i = 0; i < rows.length; i++) {
			arr.push(rows[i].pk_id);
		}
		arr.push("^");
		for (var i = 0; i < rows.length; i++) {
			arr.push(rows[i].C_no);
		}
		//主键列和显示列之间用 ^ 分割   每一项用 , 分割
		if (arr.length > 0) {//一条数据和多于一条
			returnParent(arr.join("&")); //每一项用 & 分割
		}
	}
	//导航到查看详细的按钮
	function getView() {

		var arr = $('#flexigridData').datagrid('getSelections');

		if (arr.length == 1) {
			//window.location.href = "Details/" + arr[0].pk_id;
			window.parent.popen1(arr[0].pk_id);
		} else {
			$.messager.alert('操作提示', '请选择一条数据!', 'warning');
		}
		return false;
	}

	//“导出EXCEL”按钮     在6.0版本中修改
	function flexiExport() {

		$.messager
				.confirm(
						'操作提示',
						"确认要导出EXCEL！",
						function(r) {

							if (r) {
								progress();
								//将查询条件按照分隔符拼接成字符串
								var search = "";
								$('#divQuery')
										.find(
												":text,:selected,select,textarea,:hidden,:checked,:password")
										.each(
												function() {
													search = search + this.id
															+ "&" + this.value
															+ "^";
												});

								var p = $('#flexigridData').datagrid('options').columns[0];
								var p0 = $('#flexigridData')
										.datagrid('options').frozenColumns[0];
								var field = []; //所有的列名
								var title = []; //所有的标题名称

								//alert(p0.lenth);

								$(p0).each(function() {
									if (this.title != null) {
										field.push(this.field);
										title.push(this.title);
									}

								});

								$(p).each(function() {
									if (this.title != null) {
										field.push(this.field);
										title.push(this.title);
									}

								});
								//alert(search1);
								var titlestr = removeHTMLTag(title.join(","))
								//alert(titlestr);
								//alert(field.join(","));
								$.post("Export", {
									title : titlestr,
									field : field.join(","),
									sortName : $('#flexigridData').datagrid(
											'options').sortName,
									sortOrder : $('#flexigridData').datagrid(
											'options').sortOrder,
									search : search
								}, function(res) {
									//alert(res);
									$.messager.progress('close');
									window.location.href = res;
								});
							}

						});
	}

	function progress() {
		var win = $.messager.progress({
			title : '请等待',
			text : '数据正在处理中'
		});
	}
	//js过滤HTML标签以及空格
	function removeHTMLTag(str) {
		str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
		str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
		//str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
		str = str.replace(/ /ig, ''); //去掉 
		return str;
	}
</script>

<script src="../resources/Res/My97DatePicker/WdatePicker.js"
	type="text/javascript"></script>

<base target="_self">
</head>
<body class="easyui-layout" style="padding: 3px;">
	<table id="flexigridData" fit="true">
	</table>

	<div id="divQuery" title="查询列表" class="easyui-dialog" closed="true"
		modal="false" iconcls="icon-search">

		<div class="input">
			<div class="editor-label-search">
				<label for="C_no">车牌号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_no' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_sno">车牌小号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_sno' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_Pno">场地编号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_Pno' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_type">车型代码</label>
			</div>
			<div class="editor-field-search">
				<select id="C_typeDDL_String" name="C_typeDDL_String"><option
						value="">请选择</option>
					<option value="A">A</option>
					<option value="B">B</option>
					<option value="C">C</option>
				</select>
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_master">车主</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_master' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_filesNo">档案编号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_filesNo' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_dirver">司机</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_dirver' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_GPSNO">身份证号(驾驶员)</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_GPSNO' />
			</div>
		</div>
		<!-- <div class="input">
			<div class="editor-label-search">
				<label for="C_regdate">登记日期</label>
			</div>
			<div class="editor-field-search" style="width: 600px;">
				<input type='text' id='C_regdateStart_Time'
					onclick="WdatePicker({maxDate:'#F{$dp.$D(\'C_regdateEnd_Time\');}'})" />
				到 <input type='text' id='C_regdateEnd_Time'
					onclick="WdatePicker({minDate:'#F{$dp.$D(\'C_regdateStart_Time\');}'})" />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">汇总时间</div>
			<div class="editor-field-search" style="width: 600px;">
				<input type='text' id='CostdateStart_Time'
					onclick="WdatePicker({maxDate:'#F{$dp.$D(\'CostdateEnd_Time\');}'})" />
				到 <input type='text' id='CostdateEnd_Time'
					onclick="WdatePicker({minDate:'#F{$dp.$D(\'CostdateStart_Time\');}'})" />
			</div>
		</div> -->
	</div>



</body>
</html>